﻿using System.Windows.Forms;

namespace Pitaya_IDE
{
    public class FullScreen
    {
        private static Form1 form1;
        private static int old_top = 0, old_left = 0, old_width = 0, old_height = 0;
        private static FormWindowState old_sta;
        public FullScreen(Form1 _form1)
        {
            form1 = _form1;
        }
        
        public static void F11_FullScreen()
        {
            if (form1 == null) return;

            if (!form1.FScreenFlag)
            {
                old_top = form1.Top;
                old_left = form1.Left;
                old_width = form1.Width;
                old_height = form1.Height;  // 备份位置以及大小

                old_sta = form1.WindowState;

                form1.WindowState = FormWindowState.Maximized;    //最大化窗体

                form1.Top = 0;
                form1.Left = 0;
                form1.Width = SystemInformation.PrimaryMonitorSize.Width;//屏幕宽度
                form1.Height = SystemInformation.PrimaryMonitorSize.Height;//屏幕高度

                form1.panel1_vis = false;
                form1.FScreenFlag = true;

                
                
            }
            else
            {
                form1.WindowState = old_sta;

                form1.Top = old_top;
                form1.Left = old_left;
                form1.Width = old_width;
                form1.Height = old_height;

                form1.panel1_vis = true;
                form1.FScreenFlag = false;
            }

            form1.FrameRefresh(FormWindowState.Normal == form1.WindowState);
            form1.Rd_window();
        }
    }
}

